/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.common.constant.rules;

import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;

/**
 * 子对象(关键业务应用)安全需求关联指标规则
 *
 * @author zpy
 * @version 1.0.0
 */
public enum SubBusinessReqTargetRule {
    /**身份鉴别**/
    AUTH("身份鉴别","身份鉴别"),
    /**访问控制信息完整性**/
    ACCESS_INTEGRITY("访问控制信息完整性","访问控制信息完整性"),
    /**重要信息资源安全标记完整性**/
    IMPORTANT_INTEGRITY("重要信息资源安全标记完整性","重要信息资源安全标记完整性"),
    /**不可否认性**/
    NON_REPUDIATION("不可否认性","不可否认性");

    private final String name;
    private final List<String> targetNames;

    SubBusinessReqTargetRule(String name,String... ids) {
        this.name = name;
        this.targetNames = Arrays.asList(ids);
    }

    public static SubBusinessReqTargetRule fromName(String name){
        if(StringUtils.isEmpty(name)){
            return null;
        }
        SubBusinessReqTargetRule data = null;
        for(SubBusinessReqTargetRule item : SubBusinessReqTargetRule.values()){
            if(StringUtils.equals(item.name,name)){
                data = item;
                break;
            }
        }
        return data;
    }

    public String getName(){
        return this.name;
    }

    public List<String> getTargetNames(){
        return this.targetNames;
    }
}